package com.app.dao.mysql;

import com.app.domain.QmData;
import com.app.domain.YjData;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface QmDataMapper {
    @Select("select * from qmdata where device_code=#{device_code} ORDER BY id DESC")
    List<QmData> findAll(String device_code);

    @Insert("insert into qmdata(device_code,big_carroute,main_hookheight,reserved_vicehookheight,main_hookload,reserved_vicehookload,small_carroute,reserved_smallcarroute,wind_speed,reserved_analogquantityone,reserved_analogquantitytwo,main_hookstatus,reserved_vicehookstatus,wind_speedalarm,big_carleftlimit,big_carrightlimit,small_carfrontlimit,small_carbacklimit,reserved_smallcarfrontlimit,reserved_smallcarbacklimit,hook_uplimit,reserved_vicehookuplimit,door_limit,wind_antiskidstatus,wire_drumstatus,small_car1brake1,small_car1brake2,small_car2brake1,small_car2brake2,big_carLeg_deviation,all_time,all_times,bigcar_ALM,reserved_one,reserved_two,date) values(#{device_code},#{big_carroute},#{main_hookheight},#{reserved_vicehookheight},#{main_hookload},#{reserved_vicehookload},#{small_carroute},#{reserved_smallcarroute},#{wind_speed},#{reserved_analogquantityone},#{reserved_analogquantitytwo},#{main_hookstatus},#{reserved_vicehookstatus},#{wind_speedalarm},#{big_carleftlimit},#{big_carrightlimit},#{small_carfrontlimit},#{small_carbacklimit},#{reserved_smallcarfrontlimit},#{reserved_smallcarbacklimit},#{hook_uplimit},#{reserved_vicehookuplimit},#{door_limit},#{wind_antiskidstatus},#{wire_drumstatus},#{small_car1brake1},#{small_car1brake2},#{small_car2brake1},#{small_car2brake2},#{big_carLeg_deviation},#{all_time},#{all_times},#{bigcar_ALM},#{reserved_one},#{reserved_two},#{date})")
    @Options(useGeneratedKeys = true, keyProperty = "qmData.id", keyColumn = "id")
    void save(QmData qmData);

    @SelectProvider(type = SqlProvider.class, method = "updateQmDataByField")
    void ConditionUpdate(@Param("id") String id, @Param("field") String field, @Param("value") String value);

    @Delete("delete from qmdata where date = #{date} and device_code=#{device_code}")
    void delete(@Param("date") String date, @Param("device_code") String device_code);

    @Select("SELECT device_code FROM qmdata GROUP BY device_code")
    List<String> groupByDeviceCode();
}
